package com.ikas.ai.server.module.condition.controller;

import com.ikas.ai.handle.JsonResult;
import com.ikas.ai.server.module.AbstractBean;
import com.ikas.ai.server.module.condition.service.WorkConditionService;
import com.ikas.ai.server.module.data.service.DataMeteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @menu 工况表,工况基础配置
 *
 * @author tang.xuandong
 * @version 1.0.0
 * @date 2023/5/5 10:57
 */
@RestController
@RequestMapping("/work/condition")
public class WorkConditionController extends AbstractBean {

    @Autowired
    private WorkConditionService workConditionService;
    @Autowired
    private DataMeteService dataMeteService;

    /**
     * 获取机组列表信息
     *
     * @return Json
     */
    @GetMapping("/getMachines")
    public JsonResult getMachines(@RequestParam(name = "type", required = false, defaultValue = "1") Integer type) {
        return JsonResult.ok(workConditionService.getMachineList(type));
    }

    /**
     * 根据机组id获取工况列表
     *
     * @param machineId 机组id
     * @return Json
     */
    @GetMapping("/getConditionByMachineId")
    public JsonResult getConditionByMachineId(Long machineId) {
        return JsonResult.ok(workConditionService.getWorkConditionByMachineId(machineId));
    }

    /**
     * 根据机组编号获取工况列表
     *
     * @param machineNo 机组编号
     * @return list
     */
    @GetMapping("/getConditionByMachineNo")
    public JsonResult getConditionByMachineNo(String machineNo) {
        return JsonResult.ok(workConditionService.getWorkConditionByMachineNo(machineNo));
    }

    /**
     * 获取机组、工况对应的执行响应项测点
     *
     * @param machineNo 机组编号
     * @param wfName    工况名称
     * @return 执行响应项测点
     */
    @GetMapping("/getDataMete")
    public JsonResult getDataMete(String machineNo, String wfName) {
        return JsonResult.ok(dataMeteService.getDataMeteByMachineNoAndWfName(machineNo, wfName));
    }

}
